(deftemplate persoana
    (slot nume )
    (slot sex)
    (slot parinte)
    (slot partener))

(deftemplate persoana(slot nume)(slot sex)(slot parinte)(slot partener))
(assert (persoana(nume Nemo)(sex M)(parinte Hans)(partener Armando)))
(assert (persoana(nume Ionel)(sex M)(parinte Maria)(partener George)))
(assert (persoana(nume Oana)(sex F)(parinte Maria)(partener George)))
(assert (persoana(nume Vanessa)(sex F)(parinte Mirela)(partener Vasilica)))
(assert (persoana(nume Armando)(sex M)(parinte Veta)(partener Petru)))
(assert (persoana(nume Miguel)(sex M)(parinte Veta)(partener Petru)))
(assert (persoana(nume George)(sex M)(parinte Veta)(partener Petru)))
(assert (persoana(nume Maria)(sex F)(parinte Alberta)(partener Teodor)))
(assert (persoana(nume vasilica)(sex F)(parinte Alberta)(partener Teodor)))
(assert (persoana(nume Hans)(sex M)(parinte null)(partener Armando)))
(assert (persoana(nume Mirela)(sex F)(parinte null)(partener Vasilica)))
(assert (persoana(nume Petru)(sex M)(parinte null)(partener Veta)))
(assert (persoana(nume Veta)(sex F)(parinte null)(partener Petru)))
(assert (persoana(nume Teodor)(sex M)(parinte null)(partener Alberta)))
(assert (persoana(nume Alberta)(sex F)(parinte null)(partener Teodor)))

(defrule mama 
    (persoana (nume ?nc) (parinte ?np))
    (persoana (nume ?np)(sex F))
    =>
    (printout t "Copilul " ?nc " are mama " ?np crlf)
    )
(defrule mama2 
    (persoana (nume ?nc)(parinte ?np))
    (persoana (nume ?np )(partener ?npp)); dupa partenerul de viata
    (persoana (nume ?npp) (sex f ))
    =>
    (printout t " Copilul " ?nc " are mama " ?npp crlf)
    )
(defrule partener
    (persoana (nume ?n)(partener ?np) )
    =>
    (printout t" Persoana cu numele " ?n " are ca partener pe " ?np crlf)
    )
(defrule unchi
    (persoana (nume ?n)(parinte ?np & ~null))
    =>
    (printout t "Persoana "?n " si are ca parinte "?np crlf)
    )
(defrule bunici
    (persoana (nume ?n)(parinte ?np))
    (persoana (nume ?np)(partener ?npp))
    (persoana (nume ?npp)(parinte ?nbb))
    (persoana (nume ?np)(parinte ?nb))
    (persoana (nume ?nb)(partener ?nbp))
    (persoana (nume ?nbb) (partener ?nbbp))
    =>
    
    (printout t "Persoana "?n  " are ca bunici " ?nb", " ?nbp", " ?nbb", " ?nbbp crlf)
    )
(defrule bunici2
	(persoana (nume ?n)(parinte ?np & ~null))
    (persoana (nume ?np)(parinte ?nb))
    (persoana (nume ?nb)(partener ?nbp))
	=>
    (printout t "Persoana "?n " are ca bunici " ?nb", "?nbp crlf)
    )

(run)